// function match(re) {
//   return function (str) {
//     return str.match(re);
//   }
// }

// konggeMatch = match(/\s+/g);
// let a = konggeMatch(' abc d');
// console.log(a);
// console.log(' abc d'.match(/\s+g/));

const _ = require('lodash');
const match = _.curry((re, str) => str.match(re));
const haveSpace = match(/\s+/g); // = (str) => str.match(/\s+/g);
const haveNumber = match(/\d+/g);

// console.log(haveSpace('hello world'));
// console.log(haveNumber('adsfa'));

const filter = _.curry((fn, array) => array.filter(fn));

// let filter2 = filter(item => item % 2);
filter2 = (array) => array.filter(item => item % 2);

console.log(filter2([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])); // [1,3,5,7,9];

// let filterSpace = filter(haveSpace);
filterSpace = (array) => (array.filter((str) => str.match(/\s+/g)));
console.log(filterSpace(['Lan Pang', 'xiong'])); // ['Lan Pang'];